;(function () {
    'use strict';
    angular.module('lianxi',['ui.router','common','user','question'])
        .config(['$interpolateProvider',
            '$stateProvider',
            '$urlRouterProvider',
            '$locationProvider',
            function (
            $interpolateProvider,
            $stateProvider,
            $urlRouterProvider,
            $locationProvider,
        ) {
            $interpolateProvider.startSymbol('[:');
            $interpolateProvider.endSymbol(':]');

            $locationProvider.hashPrefix('');

            $urlRouterProvider.otherwise('/home');

            $stateProvider
                .state('home',{
                    url:'/home',
                    templateUrl:"/tpl/page/home",
                })
                .state('login',{
                    url:'/login',
                    templateUrl:"/tpl/page/login",
                })
                .state('signup',{
                    url:'/signup',
                    templateUrl:"/tpl/page/signup",
                })
                .state('question',{
                    abstract:true,
                    url:'/question',
                    template:"<div ui-view></div>",
                })
                .state('question.add',{
                    url:'/add',
                    templateUrl:"/tpl/page/question_add",
                })
        }])

        .controller('HomeController',[
            '$scope',
            'TimelineService',
            function ($scope,TimelineService) {
                var win;
                $scope.Timeline = TimelineService;
                TimelineService.get();

                win = $(window);
                win.on('scroll',function () {
                    if (win.scrollTop()-($(document).height() - win.height())>-50){
                        TimelineService.get();
                    }
                })
            }
        ])

})();